package com.it.singleDocument;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.junit.Test;

import java.io.InputStream;

public class DeployProcess {

    @Test
    public void deployProcess01() {

        ProcessEngineConfiguration configuration =
                ProcessEngineConfiguration
                        .createProcessEngineConfigurationFromResource("activiti.cfg.xml");
        ProcessEngine processEngine =
                configuration.buildProcessEngine();
        System.out.println(processEngine);

        //获取repositoryService
        RepositoryService repositoryService = processEngine.getRepositoryService();
        //bpmn输入流
        InputStream inputStream_bpmn = this.getClass()
                .getClassLoader()
                .getResourceAsStream("diagram/holiday.bpmn");
        //图片的输入流
        InputStream inputStream_png = this.getClass()
                .getClassLoader()
                .getResourceAsStream("diagram/holiday.bpmn");


        //流程部署对象
        Deployment deployment = repositoryService.createDeployment()
                .addInputStream("holiday.bpmn", inputStream_bpmn)
                .addInputStream("holiday.png", inputStream_png)
                .deploy();

        System.out.println("deployment.getId() = " + deployment.getId());
        System.out.println("deployment.getId() = " + deployment.getName());

    }
}
